package com.example.dao;

import com.example.entity.Goods;
import com.example.entity.Users;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface UsersDao {
    @Select("select * from users ")
     ArrayList<Users> queryAll();

    @Delete("delete from users where uID = #{id}")
    int deleteByID(Integer id);

    @Select("select * from users where uID = #{id}")
    int selectByID(Integer id);

    @Select("select * from users where uID = #{id}")
    Users findById(Integer id);


    @Update("UPDATE users SET " +
            "uName = #{users.uname}, " +
            "uPwd = #{users.upwd}," +
            "uSex = #{users.usex}," +
            "uBirth = #{users.ubirth}, " +
            "ucity =#{users.ucity},"+
            "uphone =#{users.uphone},"+
            "uEmail = #{users.uemail}, " +
            "uQQ = #{users.uqq}, " +
            "uCredit =  #{users.ucredit} " +
            "WHERE uID =  #{users.uid}")
    int update(@Param("users") Users users);

    @Insert("insert into users(uName,uPwd,uSex,uBirth,uEmail,uQQ,uCredit)" +
            " values(#{users.uname},"+
            "#{users.upwd}," +
            "#{users.usex}, " +
            "#{users.ubirth}," +
            "#{users.uemail}," +
            "#{users.uqq}," +
            "#{users.ucredit})")
    int insert(@Param("users")Users users);
}

